// 指定考试、指定班级，指定科目的平均分
export const pjfExamClassByKemu = (scoreDataClass, kemuList) => {
    const len = scoreDataClass.length
    const total = scoreDataClass.reduce((num, item) => {
        const value = kemuList.reduce((v, cell) => {
            return v + item[cell]
        }, 0)
        return num + value
    }, 0)
    return (total / len).toFixed(1)
}

// 返回分布对象，给定最大值，以1为单位
export const getObj = (min, max, space) => {
    let obj = {}
    for (let i = min; i <= max; i = i + space) {
        obj[i] = 0
    }
    return obj
}

// 指定考试，指定班级，指定科目，分数对应人数的数组
export const scoreEchartY = (scoreDataClass, spaceList, kemuList) => {
    let obj = getObj(spaceList[0], spaceList[1], spaceList[2])
    scoreDataClass.forEach((item) => {
        let score = kemuList.reduce((num, cell) => +num + +item[cell], 0)
        score = Math.floor(score / spaceList[2]) * spaceList[2]
        obj[score] = obj[score] + 1
    })
    const list = Object.values(obj)
    return list
}
